License
@objc(LSLicense)
final class License
extension License : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Decodable, Encodable, Equatable, Hashable, NSObjectProtocol, Sendable, SendableMetatype
The License. Contains information about the license and set of methods to manupulate it.
-
Creates a new instance by decoding from the given decoder.
This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.
Declaration
Swift
required init(from decoder: any Decoder) throws -
Encodes this value into the given encoder.
If the value fails to encode anything,
encoderwill encode an empty keyed container in its place.This function throws an error if any values are invalid for the given encoder’s format.
Declaration
Swift
func encode(to encoder: any Encoder) throws -
Undocumented
Declaration
Swift
static func decode(from data: Data, configuration: Configuration) throws -> License -
License configuration. Do NOT modify directly.
Declaration
Swift
@objc let configuration: Configuration -
License key. Exists for key-based license.
Declaration
Swift
@objc var licenseKey: String? { get } -
License user. Exists for user-based license.
Declaration
Swift
@objc var user: User? { get } -
Product code.
Declaration
Swift
@objc var productCode: String { get } -
Type of license.
Declaration
Swift
@objc var licenseType: LicenseType { get } -
Information about license customer, commonly it’s a person or organization associated with the license.
Declaration
Swift
@objc var customer: Customer { get } -
Period when the license is valid.
Declaration
Swift
@objc var validityPeriod: Date? { get } -
Maintenance period for the license.
Declaration
Swift
@objc var maintenancePeriod: Date? { get } -
The first date when the license can be activated
Declaration
Swift
@objc var startDate: Date? { get } -
The date of the last sync with the LicenseSpring platform.
Declaration
Swift
@objc var lastSyncDate: Date { get } -
If license is trial.
Declaration
Swift
@objc var isTrial: Bool { get } -
If license is active.
Declaration
Swift
@objc var isActive: Bool { get } -
If license is enabled.
Declaration
Swift
@objc var isEnabled: Bool { get } -
If license was activated offline.
Declaration
Swift
@objc var isOfflineActivated: Bool { get } -
If license was activated via Air-Gap.
Declaration
Swift
@objc var isAirGapActivated: Bool { get } -
PolicyID related to AirGap activation.
Declaration
Swift
@objc var policyID: Int { get } -
Installation information related to the license.
Note
To get actual installation file information, callsynchronizemethod first.Declaration
Swift
@objc var installationFile: InstallationFile? { get } -
Hardware ID related to the license.
Declaration
Swift
@objc var hardwareID: String { get } -
License ID related to the license.
Declaration
Swift
@objc var serverID: Int64 { get } -
Indicates whether negative consumption is allowed for Consumption feature. Meaningful only for Consumption license features.
Declaration
Swift
@objc var allowNegativeConsumptions: Bool { get } -
Is running a license on a virtual machine prevented.
Declaration
Swift
@objc var preventVM: Bool { get } -
Activation date related to the license
Declaration
Swift
@objc var activationDate: Date? { get } -
Company related to the license
Declaration
Swift
@objc var company: Company? { get } -
Current state of the license.
Declaration
Swift
@objc var state: LicenseState { get } -
If license have been expired.
Declaration
Swift
@objc var isExpired: Bool { get } -
Fast and simple way to check current local state of the license.
Note
Equivalent to isEnabled && isActive && !isExpired.Note
It’s just basic check, you cannot be 100% sure that license is valid without online license check. You still need to perform full license check for better safety.Declaration
Swift
@objc var isValid: Bool { get }Return Value
If license is valid.
-
If license copy is unlicensed.
Declaration
Swift
@objc var isUnlicensedCopy: Bool { get } -
Indicates whether the maintenance period for the current license has expired.
Declaration
Swift
@objc var isMaintenancePeriodExpired: Bool { get } -
Grace period of the license.
Note
Meaningful only forsubscriptionlicense.Declaration
Swift
@objc var gracePeriod: TimeInterval { get } -
Check license for validity on the LicenseSpring platform.
Throws
Error if remote or local checks fail.Declaration
Swift
@objc func fullCheck(env: String? = nil) throwsParameters
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
-
Asynchronous wrapper for full license check that avoids blocking the main thread.
Declaration
Swift
@objc func fullCheckAsync(env: String? = nil, completion: @escaping ((any Error)?) -> Void)Parameters
envOptional environment identifier.
completionCompletion handler called with success or error.
-
Check license for validity offline.
Throws
Error if check fails.Declaration
Swift
@objc func localCheck() throwsReturn Value
Boolean indicates if local check passed or not.
-
Retrieves fresh license information from the LicenseSpring platform.
Throws
Error if synchronization fails.Declaration
Swift
@objc func synchronize(env: String? = nil) throws -
How many times license already been activated.
Declaration
Swift
@objc var timesActivated: Int { get } -
How many times license can be activated.
Declaration
Swift
@objc var maxActivations: Int { get } -
Deactivate the license.
Throws
Error if deactivation fails.Declaration
Swift
@objc func deactivate() throws -
Updates license with offline update file.
Throws
Error if update fails.Declaration
Swift
@objc func updateOffline(with file: URL) throws -
Creates offline deactivation file request.
Throws
Error if creation of deactivation request fails.Declaration
Swift
@objc func deactivateOffline(preferredRequestFile: URL? = nil) throws -> URLParameters
preferredRequestFileOptional custom deactivation request file location. ‘~/Desktop/ls_deactivation.req’ by default.
Return Value
Location of offline deactivation file request.
-
Generate air gap Deactivation code.
Throws
LSError if code generation fails.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) func generateAirGapDeactivationCode(initializationCode: String) throws -> StringParameters
initializationCodeCode received from the air gap activation portal.
Return Value
Air gap Dectivation code.
-
Verify Confirmation code and deactivate air gap license.
Throws
LSError in case confirmation code from the air gap activation portal is invalid.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) func deactivateAirGap(confirmationCode: String) throwsParameters
confirmationCodeCode received from the air gap activation portal.
-
Product features available for the license.
Declaration
Swift
@objc var features: [LicenseFeature] { get } -
Updates feature consumption by some diff (positive or negative).
Throws
Error if update fails.Declaration
Swift
@objc func updateFeatureConsumption(code: String, difference: Int) throwsParameters
codeFeature code.
differenceDifference of consumption number.
-
Sync Consumption Feature(s) with the LicenseSpring platform.
Note
Meaningful only for Consumption features.Throws
Error if sync fails.Declaration
Swift
@objc func syncFeatureConsumption(code: String?) throwsParameters
codeCode of the license feature that need to be synchronized. If
nil, sync all consumption features. -
If the license is floating type. Meaningful only for Floating license.
Declaration
Swift
@objc var isFloating: Bool { get } -
If the license is floating type. Meaningful only for Floating license.
Declaration
Swift
@objc var isOfflineFloating: Bool { get } -
Maximum number of simultaneous license users (devices or instances). Meaningful only for Floating license.
Declaration
Swift
@objc var maxFloatingUsers: Int { get } -
Current number of floatings slots in use, including this user (instance). The value can be actualized with
synchronizemethod call. Meaningful only for Floating license.Declaration
Swift
@objc var floatingInUseCount: Int { get } -
Timeout of the floating license. Meaningful only for Floating license.
Declaration
Swift
@objc var floatingTimeout: TimeInterval { get } -
Floating user (client) or instance id that was set during registration via
FloatingClient. Meaningful only for Floating license.Declaration
Swift
@objc var floatingClientId: String? { get } -
Floating license validity end date. Meaningful only for Floating license.
Declaration
Swift
@objc var floatingEndDate: Date? { get } -
How many times license has been transferred between devices.
Declaration
Swift
@objc var transferCount: Int { get } -
Register floating license using floatingClientId
In order to keep floating license alive you should check (register) it periodically. This is equivalent to
synchronizemethod call.Meaningful only for Floating license.
Declaration
Swift
@objc func registerFloatingLicense() throws -
Revoke floating license, typically should be called at the end of app execution.
This call will also release (return) borrowed license.
Declaration
Swift
@objc func releaseFloatingLicense() throws -
If the license is borrowed. Meaningful only for Floating license.
Declaration
Swift
@objc var isBorrowed: Bool { get } -
If the license can be borrowed. Meaningful only for Floating license.
Declaration
Swift
@objc var canBorrow: Bool { get } -
The license max borrow time in seconds. Meaningful only for Floating license.
Declaration
Swift
@objc var maxBorrowTime: TimeInterval { get } -
IsBundleActivated
Declaration
Swift
@objc var isBundleActivated: Bool { get } -
Borrow floating license for provided time interval. Meaningful only for floating licenses.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/floating/borrow.
Declaration
Swift
@objc func borrow(for interval: TimeInterval) throws -
Borrow floating license till provided end date. Meaningful only for floating licenses.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/floating/borrow.
Declaration
Swift
@objc func borrow(until date: Date?) throws -
Custom data fields available for the license.
Declaration
Swift
@objc var customFields: [CustomField] { get } -
Internal order id.
Declaration
Swift
@objc var orderStoreID: String? { get } -
Metadata JSON.
Declaration
Swift
@objc var metadata: Data? { get } -
Information about the product this license is belong to.
Declaration
Swift
@objc var productDetails: ProductDetails { get } -
Array of variables bound to license concrete device ID.
Declaration
Swift
@objc var deviceVariables: [DeviceVariable] { get } -
Sends device-specific variables to the LicenseSpring platform.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/track_device_variables.
Declaration
Swift
@objc func sendDeviceVariables(_ variables: [String : String]) throwsParameters
variablesDictionary of name-value pairs.
Return Value
Array of variables linked to the current running device ID.
-
Requests device-specific variables from the LicenseSpring platform. If succeeds, property
deviceVariablesis also updated.Note
Please note this data will be linked to the current running device ID.Throws
Error if sending data fails.
Note
More at /api/v4/get_device_variables.
Declaration
Swift
@objc func requestDeviceVariables() throws -> [DeviceVariable] -
Request all available versions for the current license.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestAvailableVersions() throws -> [AvailableVersion]Return Value
An array of versions available for the license.
-
Request installation information for the current license.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestInstallationFile(version: String? = nil) throws -> InstallationFileParameters
versionDesired product (app) version, optional. If not provided, the last available version assumed.
Return Value
Installation information related to the license.
-
Change password for user based license.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/change_password
Declaration
Swift
@objc func changePassword(password: String, newPassword: String) throwsParameters
passwordCurrent user password.
newPasswordNew user password.
-
If unlimited number or consumptions is allowed.
Note
Meaningful only for Consumption license.Declaration
Swift
@objc var allowUnlimitedConsumptions: Bool { get } -
If reset consumption is enabled. Refer to value in
consumptionPeriod.Note
Meaningful only for Consumption feature type.Declaration
Swift
@objc var isResetConsumptionEnabled: Bool { get } -
Value of reset consumption period. Makes sense only if
isResetConsumptionEnabledistrue.Note
Meaningful only for Consumption feature type.Declaration
Swift
@objc var consumptionPeriod: ConsumptionPeriod { get } -
If it’s allowed to go over
maxConsumptionOverage.Note
Meaningful only for Consumption based license.Declaration
Swift
@objc var isConsumptionOverageAllowed: Bool { get } -
Maximum extra consumption value or 0 for
unlimitedvalue. 0 if license type is not Consumption.Declaration
Swift
@objc var maxConsumptionOverage: Int { get } -
Change local consumption counter for consumption license.
Note
Meaningful only for Consumption based license.Throws
Error if sending data fails.Declaration
Swift
@objc func updateConsumptions(difference: Int) throwsParameters
differenceConsumption value to be added or removed (if passed as negative).
-
Current total consumption or 0 if license type is not Consumption.
Note
Meaningful only for Consumption based license.Declaration
Swift
@objc var consumptions: Int { get } -
Maximum consumption value or 0 if license type is not Consumption.
Note
Meaningful only for Consumption based license.Declaration
Swift
@objc var maxComsumptions: Int { get } -
Number of local consumptions not synchornized with LicenseSpring platform. May be negative.
Note
Meaningful only for Consumption feature type.Declaration
Swift
@objc var localConsumptionsDelta: Int { get } -
Sync Consumption license with the server.
Throws
Error if sync fails.Note
Meaningful only for Consumption based license.Declaration
Swift
@objc func syncConsumptions() throws -
Undocumented
Declaration
Swift
func getLicenseWatchdogTimeout() -> UInt? -
Undocumented
Declaration
Swift
@objc func registerFloatingFeature(_ licenseFeature: LicenseFeature) throws -
Undocumented
Declaration
Swift
@objc func releaseFloatingFeature(_ licenseFeature: LicenseFeature) throws